package com.kingwang.training.designpattern.composite;

import com.kingwang.training.designpattern.composite.bo.Organization;
import com.kingwang.training.designpattern.composite.bo.OrganizationNode;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        OrganizationNode root = new Organization("企业");

        OrganizationNode dep1 = new Organization("部门1");
        OrganizationNode group1 = new Organization("车间11");
        group1.add(new Organization("班组111"));
        dep1.add(group1);

        OrganizationNode dep2 = new Organization("部门2");
        dep2.add(new Organization("小组21"));

        root.add(dep1);
        root.add(dep2);

        root.visit();
    }
}
